package com.easybacklog.client.webservices;

import com.easybacklog.client.model.ProjectFeature;
import com.google.gwt.json.client.JSONObject;

public class ConvertJsonpToFeatureFile {

	public static ProjectFeature convert(ProjectFeature feature,
			JSONObject entry) {

		feature.setFileContent(ConvertJsonp.convertToString(entry
				.get("fileContent")));

		feature.setFeatureName(ConvertJsonp.convertToString(entry
				.get("featureName")));

		feature.setFeatureDescription(ConvertJsonp.convertToString(entry
				.get("featureDescription")));

		if (entry.get("priority") != null
				&& !ConvertJsonp.convertToString(entry.get("priority")).equals(
						"null")) {

			feature.setPriority(new Integer(ConvertJsonp.convertToString(entry
					.get("priority"))));
		}

		if (entry.get("estimate") != null
				&& !ConvertJsonp.convertToString(entry.get("estimate")).equals(
						"null")) {

			feature.setEstimate(new Integer(ConvertJsonp.convertToString(entry
					.get("estimate"))));
		}

		feature.setStatus(ConvertJsonp.convertToString(entry.get("status")));

		return feature;
	}

}
